package org.demo.cnck.controller.vm;


public class HttpResult {
    private Object data;
    private int code;
    private String message;
    private HttpResult.Result result;

    HttpResult(Object data, int code, String message, HttpResult.Result result) {
        this.result = HttpResult.Result.SUCCESS;
        this.data = data;
        this.code = code;
        this.message = message;
        this.result = result;
    }

    public Object getData() {
        return data;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Result getResult() {
        return result;
    }

    public static HttpResult.HttpResultBuilder builder() {
        return new HttpResult.HttpResultBuilder();
    }


    public static class HttpResultBuilder {
        private Object data;
        private int code;
        private String message;
        private HttpResult.Result result;

        HttpResultBuilder() {
        }

        public HttpResult.HttpResultBuilder data(Object data) {
            this.data = data;
            return this;
        }

        public HttpResult.HttpResultBuilder code(int code) {
            this.code = code;
            return this;
        }

        public HttpResult.HttpResultBuilder message(String message) {
            this.message = message;
            return this;
        }

        public HttpResult.HttpResultBuilder result(HttpResult.Result result) {
            this.result = result;
            return this;
        }

        public HttpResult build() {
            return new HttpResult(this.data, this.code, this.message, this.result == null ? Result.SUCCESS : this.result);
        }

    }

    public static enum Result {
        SUCCESS,
        FAIL;

        private Result() {
        }
    }
}
